package cn.test;

import cn.thread.MyThread;

/**
 * 守护线程 用户线程
 */
public class ThreadDaemon {
    public static void main(String[] args) {
        //主进程设置名字叫刘备
        Thread.currentThread().setName("刘备");
        MyThread thread1=new MyThread();
        MyThread thread2=new MyThread();
        //优先级都是5 会随机抢占cpu 随机执行
        thread1.setName("张飞");
        thread2.setName("关羽");
        //设置张飞关羽为守护线程
        thread1.setDaemon(true);
        thread2.setDaemon(true);
        thread1.start();
        thread2.start();
        for (int i=1;i<10;i++){
            System.out.println(Thread.currentThread().getName()+i);
        }
    }
}
